/*
    This file is part of the substandard lisp implementation of Standard Lisp
    Copyright (C) 2011 Nicky Nickell

    substandard lisp is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

function std_times(a, env) {
  var args = homogenize_args(a[0]);

  if (args[0].type == TYPE_INTEGER) {
    var product = BigInteger(1);
    for (var i = 0; i < args.length; i++) {
      product = product.multiply(args[i].value);
    }
    return new lisp_integer(product);
  } else {
    var product = 1;
    for (var i = 0; i < args.length; i++) {
      product *= args[i].value;
    }
    return new lisp_floating(product);
  }
}

/*---
name: times
arity: 0
rest: true
ftype: FTYPE_EXPR

synonyms:
  - '*'

argument-types:
  - CLASS_NUMBER

doc: |
  explaining what times is / how it is used!

tests: |
  (times 1 1) -> 1
  (times 10 2) -> 20
  (times 10 2.5) -> 25
  (times 2.5 4) -> 10
  (times 2 2 2) -> 8
...*/
